import { Controller, Delete, Get, Param, Post, Put } from "@nestjs/common";
import { promises } from "dns";
import { BookCreateDto } from "src/core/dto/book-create.dto";

@Controller()
export class BookController {
    @Get()
    async searchUser(): Promise<BookCreateDto[]> {
        return [];
    }
    @Get(':id')
    getUser(@Param('id') id: string): Promise<BookCreateDto> {
        return Promise.resolve({
            id,
            title: '西游记',
            author: '吴承恩',
            publishYear: 1698,
            isbn: '156848',
            createTime: '2021-08-09 00:00:00',
            updateTime: '2029-08-09 00:00:00'
        })
    }
    @Post()
    createUser(): Promise<BookCreateDto> {
        return Promise.resolve({
            id: '45',
            title: '西游记',
            author: '吴承恩',
            publishYear: 1698,
            isbn: '156848',
            createTime: '2021-08-09 00:00:00',
            updateTime: '2029-08-09 00:00:00'
        })
    }

    @Put(':id')
    updateUser(@Param('id') id: string): Promise<BookCreateDto> {
        return Promise.resolve({
            id,
            title: '西游记',
            author: '吴承恩',
            publishYear: 1698,
            isbn: '156848',
            createTime: '2021-08-09 00:00:00',
            updateTime: '2029-08-09 00:00:00'
        })
    }
    @Delete(':id')
    deleteUsers(@Param('id') id: string): string {
        return `删除图书${id}`;
    }

}